﻿using OnlineAuction.Business;
using OnlineAuction.Entity;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace OnlineAuction
{
    public partial class Bid : System.Web.UI.Page
    {
        public string ck = "null";
        public AuctionDTO auction;
        public string aid;
        public long lastPrice;
        public bool isSeller = false;
        public string isNormal = "true";
        public double increment;
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Request.QueryString["AuctionID"] != null)
            {
                aid = Request.QueryString["AuctionID"].ToString();
                AuctionBO bo = new AuctionBO();
                int auctionID = int.Parse(aid);
                auction = bo.ViewDetailItem(auctionID);
                imgItemImage1.ImageUrl = auction.ItemImage1;
                lbItemName.Text = auction.ItemName;
                lbBidPrice.Text = "Current price: " + auction.CurrentPrice.ToString();
                lbLastBidPerson.Text = "Top bidder: " + auction.Buyer;
                lbSeller.Text = "Seller: " + auction.Seller;
                lbLeftDay.Text = auction.LeftDays;
                lbLeftHours.Text = auction.LeftHours;
                lbLeftMinutes.Text = auction.LeftMinutes;
                lbLeftSeconds.Text = auction.LeftSeconds;
                lbItemDescription.Text = auction.ItemDescription;

                if (auction.AutionTypeName.CompareTo("normal") != 0)
                {
                    txtBidPrice.Enabled = false;
                    lbIncrement.Text = "(Bid to add " + auction.Increment + "$ )";
                    increment = double.Parse(auction.Increment.ToString());
                    isNormal = "false";
                }
                if (Request.Cookies["UserInfo"] == null) ck = "null";
                else
                {
                    ck = Request.Cookies["UserInfo"]["UserName"].ToString();
                    if (ck.CompareTo(auction.Seller) == 0) isSeller = true;
                }
            }
            //Console.WriteLine("LOAD");
        }
    }
}